package com.czk.gulimall.seckill.scheduled;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Author:ChenZhangKun
 * @Date: 2022/6/14 21:49
 */
@Slf4j
@Component
@EnableScheduling
@EnableAsync // 开启异步任务
public class HelloSchedule {
    /**
     * 定时任务不应该阻塞，默认是阻塞的
     * 1 可以让业务运行以异步的方式，自己提交到线程池
     *   CompletableFuture.runAsync(()->{
     *
     *   })
     * 2 支持定时任务线程池 设置TaskSchedulingProperties
     * 3 让定时任务异步执行     @Async
     *
     */
    @Async
    @Scheduled(cron = "* * * ? * 2")
    public void hello(){
        log.info("xxxx");

    }
}
